import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 系统日志信息 */
export interface SysLog {
          deviceId: number; // 设备ID
          facility: string; // 设施类型
          priority: string; // 日志优先级数值
          level: string; // 日志严重性等级
          tag: string; // 日志的标签
          timestamp?: string | Dayjs; // 日志接收到的时间戳
          program: string; // 生成日志的程序或进程名称，例如
          msg: string; // 日志的原始消息内容
          seq: number; // ID
  }

// 系统日志 API
export const SysLogApi = {
  // 查询系统日志分页
  getSysLogPage: async (params: any) => {
    return await request.get({ url: `/business/sys-log/page`, params })
  },

  // 查询系统日志详情
  getSysLog: async (id: number) => {
    return await request.get({ url: `/business/sys-log/get?id=` + id })
  },

  // 新增系统日志
  createSysLog: async (data: SysLog) => {
    return await request.post({ url: `/business/sys-log/create`, data })
  },

  // 修改系统日志
  updateSysLog: async (data: SysLog) => {
    return await request.put({ url: `/business/sys-log/update`, data })
  },

  // 删除系统日志
  deleteSysLog: async (id: number) => {
    return await request.delete({ url: `/business/sys-log/delete?id=` + id })
  },

  /** 批量删除系统日志 */
  deleteSysLogList: async (ids: number[]) => {
    return await request.delete({ url: `/business/sys-log/delete-list?ids=${ids.join(',')}` })
  },

  // 导出系统日志 Excel
  exportSysLog: async (params) => {
    return await request.download({ url: `/business/sys-log/export-excel`, params })
  },
}